DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomImage Class / SetSimpleMasking Method / SetSimpleMasking(Int32[],MaskMode) Method

Frame numbers of the frames for subtraction

The subtraction mode to use
Example

In This Topic
    SetSimpleMasking(Int32[],MaskMode) Method
    In This Topic
    Sets an int array as frame numbers of the mask frames for subtraction
    Syntax
    'Declaration
     
    
    Public Overloads Sub SetSimpleMasking( _
       ByVal Frames() As System.Integer, _
       ByVal mode As MaskMode _
    ) 
    public void SetSimpleMasking( 
       System.int[] Frames,
       MaskMode mode
    )

    Parameters

    Frames

    Frame numbers of the frames for subtraction

    mode
    The subtraction mode to use
    Example
    // Basic Example:
    DicomImage image = new DicomImage("your_dicom_image.dcm");
    image.SetSimpleMasking(1, MaskMode.AverageSubtraction);
                    
    // Retrieving masking values from the DICOM image
    DicomImage image = new DicomImage("your_dicom_image.dcm");
    MaskMode mode = MaskMode.AverageSubtraction;
    List<int> maskFrameNumbers = new List<int>() { 1 };
                        
    // Retrieve Mask Subtraction Sequence if it exists 
    var maskSubtractionSequence = image.DataSet[Keyword.MaskSubtractionSequence].Value as DicomDataSetCollection;
    var firstItem = maskSubtractionSequence[0];
    if (firstItem[Keyword.MaskOperation].ExistsWithValue)
    {
        string maskOperation = firstItem[Keyword.MaskOperation].Value.ToString().ToUpper();
        if (maskOperation != null)
            mode = GetMaskMode(maskOperation);
    }
                        
    if (firstItem[Keyword.MaskFrameNumbers].ExistsWithValue)
    {
        ushort[] maskFrameNumbersUShort = firstItem[Keyword.MaskFrameNumbers].Value as ushort[];
        maskFrameNumbers = maskFrameNumbersUShort.Select(f => (int)f).ToList();
    }
                        
    // Apply simple masking with extracted mask frames and mode
    image.SetSimpleMasking(maskFrameNumbers.ToArray(), mode);
                        
    private MaskMode GetMaskMode(string dicomMaskOperation)
    {
        switch (dicomMaskOperation)
        {
            case "AVG_SUB":
                return MaskMode.AverageSubtraction;
            case "MIN":
                return MaskMode.Minimum;
            case "MAX":
                return MaskMode.Maximum;
            case "TID":
                return MaskMode.TimeDifference;
            case "REV_TID":
                return MaskMode.ReverseTimeDifference;
            default:
                return MaskMode.None; 
        }
    }
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also